<?php 
/**
 * 登录
 */
class c_login extends core_base_c {
	/**
	 * 登录
	 * @param string $inPath
	 */
	function pageindex($inPath) {
		$ajax = (int)$_GET['ajaxpost'];
		if($_POST){
			$backUrl = $_POST['url'];
			$post = SUtil::specialhtml($_POST);
			$mUser = new core_m_user();
			$rs = $mUser->login($post);
			if($rs){
				if($backUrl){
					$msg['url'] = $backUrl;
				}
				$msg['state'] = 1;
				$msg['msg'] = '登录成功！';
			}else{
				$msg['state'] = 0;
				$msg['msg'] = $mUser->getError();
			}
			if($ajax==1){
				return json_encode($msg);
			}else{
				$backUrl = $backUrl?$backUrl:'/';
				$this->redirect($backUrl);
			}
		}
		$this->params ['url'] = $_GET['url'];
		if($ajax==1){
			return $this->render("login/ajax.html",$this->params);
		}else{
			return $this->render("login/index.html",$this->params);
		}
	}
	/**
	 * 退出
	 * @param string $inPath
	 */
	function pagelogout($inPath) {
		$cookie['key'] = '';
		SUtil::ssetcookie($cookie,-1);
		$this->redirect('/');
	}
	/**
	 * 验证码
	 */
	function pagecaptcha(){
		session_start();
		$cap = new SCaptcha();
		$code = $cap->CreateImage();
	}
}
?>